#!/usr/bin/env python

# This script expects your out/Debug directory to be compiling for linux on
# a linux machine. If this is not your case just compile protoc and run the
# command on the last line of the script (from within
# //third_party/protobuf/src).

import os
src_dir = os.path.abspath(os.path.join(os.path.dirname(__file__),'..','..'))
out_build_dir = 'out/Debug'

def r(c):
  print c
  os.system(c)

os.chdir(src_dir)
r('gn gen {}'.format(out_build_dir))
r('ninja -C {} protoc'.format(out_build_dir))
os.chdir('third_party/protobuf/src')
protoc = os.path.join(src_dir,'{}/protoc'.format(out_build_dir))
r('{} --python_out=../python google/protobuf/descriptor.proto'.format(protoc))

